﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Model;
using Utility;
using System.Windows.Forms;
using System.Data;
using IBLL;
using BLL.Action;
using Model.WebService;

using DALFactory.DataBase;
using AppToolKit.Core.Context.Spring;
using CenterDateAchieve.Test.Init;
using System.Collections.Specialized;
using Model.TransfersConfig;
using BLL.Action.Core.Base;
namespace CenterDateAchieve.Test
{
    [TestFixture]
    public class XmlTest
    {
        private ServerContextFixure fixure_;
        private ContextAware ContextAwareSlot;
        private AccessHelper helper_;
        [TestFixtureSetUp]
        public void FixureSetup()
        {
            fixure_ = new ServerContextFixure();
            //MaintBusiness_ = (IMaintBusiness)fixure_.LoadObject(typeof(IMaintBusiness));
            NameValueCollection properties = new NameValueCollection();
            properties["showDateTime"] = "true";
            ContextAwareSlot = (ContextAware)fixure_.LoadObject(typeof(ContextAware));
            // set Adapter
            Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);
            //MaintBusiness_ = new MaintBusiness();
            //ContextAwareSlot.AutowireObject(MaintBusiness_);
            helper_ = (AccessHelper)fixure_.LoadObject(typeof(AccessHelper));
        }
        [TestFixtureTearDown]
        public void TearDown()
        {
            fixure_.Dispose();
        }
        [Test]
        public void xml()
        {
           

            ColumnDefine define = new ColumnDefine();
            define.Column = "col";
            define.ControlName = "txt_col";
            define.Descript = "累";
            define.Type = DataType.STRING;
            define.Value = "xxxxx";
            List<ColumnDefine> list = new List<ColumnDefine>();
            list.Add(define);
            list.Add(define);
            XmlReadWriteHelper.Serialize<List<ColumnDefine>>(list, @"c:\\xx2.xml");
        }
        [Test]
        public void testControl()
        {

            helper_.ExecuteNonQuery(System.Data.CommandType.Text, "update task set descript='dddd1'");
          DataSet ds= helper_.GetDataSet(System.Data.CommandType.Text,"select descript from task");
           Console.Write(ds.Tables[0].Rows[0][0]);
        }
        [Test]
        public void testsss()
        {
            string str = "Model.EntityKey,Model";

            Type t = Type.GetType(str);

        }
        [Test]
        public void testtr()
        {
            IAction action = new ActionDefault();
            WebServiceParam Param = new WebServiceParam();
            Param.Url = "http://220.179.120.83/DataInterface123/wsDataInterface.asmx";
            //Param.ClassName = "BLL.Action.Transfer.WebService.wsDataInterface,BLL.Action.Transfer";
            //List<object> objs = new List<object>();
            //string str = 
            //objs.Add(str);
            Param.DataSource = "select * from typim";
            action.Execute(Param);
        }
        [Test]
        public void testEntity()
        {
            DataTrans data = new DataTrans();

            Entity entity = new Entity();
            EntityKey key = new EntityKey();
            ColumnDefine define = new ColumnDefine();
            define.Column = "code";
            define.ControlName = "txt_code";
            define.Descript = "代码";
            
            define.Type = DataType.STRING;
            if (key.Keys == null)
                key.Keys = new List<ColumnDefine>();
            key.Keys.Add(define);
            entity.PrimaryKey = key;

            entity.TalbeName = "task";
            if (entity.Cols == null)
                entity.Cols = new List<ColumnDefine>();
            entity.Cols.Add(define);
            entity.Cols.Add(define);
            entity.Cols.Add(define);

            data.Entity = entity;
            XmlReadWriteHelper.Serialize<DataTrans>(data, @"c:\ss1.xml");
        }
        [Test]
        public void testssds()
        {
            DataTrans data = XmlReadWriteHelper.Deserialize(typeof(DataTrans), @"D:\students\dist\CenterDateAchieve\Config\Mapping\grp_base_hotel.xml") as DataTrans;
        }
        [Test]
        public void testststst()
        {
            Author author = new Author();
            author.ClassName = "fasfdas";
            author.SoapHeaderFiled = "fasdfas";
            SoapHeaderConfig c = new SoapHeaderConfig();
            c.PassWord = "foxhis";
            c.User = "foxhis";
            c.PassWordFiled = "PassWord";
            c.UserFiled = "User";         
            c.SoapHeaderName = "fad";
            author.Header = c;
            List<Author> list = new List<Author>();
            list.Add(author);
            list.Add(author);
            
            XmlReadWriteHelper.Serialize<List<Author>>(list, @"c:\xml112.xml");

        }
        [Test]
        public void testTransfer()
        {
           //string st= "BLL.Action.Transfer.WebService.wsInterface,BLL.Action.Transfer";
           //Type t = Type.GetType(st);
           //object o = Activator.CreateInstance(t);
        }
    }
}
